﻿using _1._12._2015_TodoWebAPI.Data;
using _1._12._2015_TodoWebAPI.Models;
using _1._12._2015_TodoWebAPI.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using _1._12._2015_TodoWebAPI.Adapters;
using Microsoft.AspNet.Identity;

namespace _1._12._2015_TodoWebAPI.Controllers
{
    [Authorize]
    public class apiTodoController : ApiController
    {
        private ITodoAdapter _adapter;

        public apiTodoController()
        {
            _adapter = new TodoDataAdapter();
        }

        public IHttpActionResult Get()
        {
            List<TodoViewModel> models = _adapter.GetTodos(User.Identity.GetUserId());

            var result = models.ToFirebaseResult(m => m.Id);
            
            return Ok(result);
        }

        public IHttpActionResult Get(int id)
        {
            return Ok("test");
        }

        public IHttpActionResult Put(int id, TodoViewModel model)
        {
            return Ok();
        }
    }
}
